from math import *

ans = 0

for i in range(1, 2020):
    num = str(i)
    if "2" in num or "0" in num or "1" in num or "9" in num:
        ans += pow(i, 2)

print(int(ans))
